package cn.micai.base.lambda;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 描述：
 * <p>
 *
 * @author: 赵新国
 * @date: 2018/6/21 17:11
 */
public class FilterANullValueFromAStreamExample {

    public static void main(String [] args) {

        Stream<String> languages = Stream.of("java", "python", "node", null, "ruby", null, "php");

        /*List<String> result = languages.collect(Collectors.toList());*/

        /*List<String> result = languages.filter(x -> x != null).collect(Collectors.toList());*/

        List<String> result = languages.filter(Objects::nonNull).collect(Collectors.toList());

        result.forEach(System.out::println);

    }
}
